<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>

<!DOCTYPE html>
<html>

<head>

    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">

    <title>打印</title>
    <link href="${path}/css/bootstrap.min.css?v=3.3.6" rel="stylesheet">
    <link href="${path}/css/font-awesome.css?v=4.4.0" rel="stylesheet">

    <link href="${path}/css/animate.css" rel="stylesheet">
    <link href="${path}/css/style.css?v=4.1.0" rel="stylesheet">
    <link href="${path}/css/template.css" rel="stylesheet">

    <style>
        input,select{
            background: #ffffff !important;
            border-color: #ffffff !important;
        }
        select{
            appearance:none;
            -moz-appearance:none;
            -webkit-appearance:none;
        }
    </style>
</head>

<body class="white-bg">

    <!-- 全局js -->
    <script src="${path}/js/jquery.min.js?v=2.1.4"></script>
    <script src="${path}/js/bootstrap.min.js?v=3.3.6"></script>
    <script src="${path}/js/template.engine.js"></script>

    <script type="text/javascript">
//        window.print();
        $(document).ready(function () {
            var data = ${data };

            $.ajax({
                type: "post",
                url: "${path}/api/household/print",
                data: data,
                dataType: "json",
                traditional: true,
                success: function (result) {
                    if (result.code == "${result_success}") {

                        $(result.data).each(function (index) {

                            var archivesData = eval('('+this.data+')');

                            if(archivesData == null)
                                archivesData = this.master
                            else
                                for(var key in this.master){
                                    archivesData[key] = this.master[key];
                                }

                            var te = templateEngine();

                            var tp = te.parsing(this.template.template,archivesData);

                            var html = '';
                            if(index != 0)
                                html += '<div  style="page-break-before:always;"><br /></div>';
                            html += '\
                                <div id="'+index+'" class="wrapper wrapper-content p-xl">\
                                    <div class="ibox-content p-xl">\
                                        '+tp+'\
                                    </div>\
                                </div>\
                                ';

                            $('body').append(html);

                            te.formula('body #'+index,this.master);
                        });

                        window.print();
                    }else {
                        layer.msg(result.data);
                    }
                },
            });

        });
    </script>

</body>

</html>
